<?php
# Simple test script for testing python cmd-line POST to RASS.
#
# Copyright (C) 2008 rambla.be
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

// p.add_option('-s', '--svr', dest = "svr", help = "Service base uri (e.g. 'rass.cdn01.rambla.be')", default="rambla06-rass.rambla.be")
// p.add_option('-u', '--user', dest = "user", help = "User account name")
// p.add_option('-p', '--pwd', dest = "pwd", help = "User account password")
// p.add_option('-d', '--dir', dest = "dir", help = "Path (starting from the user's CDN rootdir) to the directory.")
// p.add_option('-f', '--file', dest = "file", help = "Filename, including extension.")
// p.add_option('-l', '--location', dest = "location", help = "Local path to the file that needs to be posted.")

define('SVR', 'rass.cdn01.rambla.be');
define('USER', 'xxx');
define('PWD', 'xxx'); 
define('DIRPATH', 'xxx');  # path to be added to item/ in the POST uri
define('RASS_FILENAME', 'xxx');  # filename for the slug header
define('LOCALPATH', 'xxx');  # local path to transcoded file

# construct the cmd
$cmd = sprintf("python rasspostcli.py -s '%s' -u '%s' -p '%s' -d '%s' -f '%s' -l '%s'", 
               SVR, USER, PWD, DIRPATH, RASS_FILENAME, LOCALPATH);

# execute cmd
ob_start();
passthru($cmd, $ret);
$out = ob_get_contents();
ob_end_clean();

# show cmd results
echo "\n\nStdout data:\n";
echo rtrim($out);
echo "\n\nReturn val:\n";
echo $ret;
